axios.interceptors.request.use(req=>{
    req.headers.accesstoken=localStorage.getItem("accessToken");
    return req;
})
axios.interceptors.response.use(resp=>{
    if (resp.headers.accesstoken!=null){
        localStorage.setItem("accessToken",resp.headers.accesstoken)
    }
    return resp;
})

new Vue({
    el:"#app",
    data:{
        storeList:{},
        storeDetail:{
            attachments:[],
            storeInfo:{
                storeInfoLogo:"",
                storeInfoName:"",
                storeInfoAddress:"",
                storeInfoLinkMan:"",
                storeInfoPhone:"",
                storeInfoOrderPhone:"",
                storeInfoInitiatePrice:"",
                storeInfoDphPrice:"",
                storeInfoLicense:"",
                storeInfoPermit:"",
                storeInfoStoreScore:"",
                storeInfoDishesScore:"",
                storeInfoDphScore:"",
                storeInfoEvaluateDate:"",
                storeInfoStoreIntro:"",
                storeInfoCreateUser:"",
                storeInfoCreateDate:"",
                storeInfoUpdateUser:"",
                storeInfoUpdateDate:"",
                storeInfoRemarks:""
            }
        },
        condition: "",
        showDetailWindow:false
    },
    methods:{
        loadAllStoreList(pageIndex,pageSize,condition){
            axios.get("/storeInfo/list",{
                params:{
                    pageIndex:pageIndex,
                    pageSize:pageSize,
                    condition:condition
                }
            }).then(resp=>{
                console.log(resp)
                this.storeList=resp.data.data
            })
        },handleSizeChange(pageSize){
            this.loadAllStoreList(1,pageSize,this.condition)
        },handleCurrentChange(pageNum){
            this.loadAllStoreList(pageNum,this.storeList.pageSize,this.condition)
        },findByCondition(){
            this.loadAllStoreList(1,3,this.condition)
        },
        viewDetail(obj) {
            axios.get("/storeInfo/detail", {
                params: {
                    storeInfoId: obj.storeInfoId
                }
            }).then(resp => {
                this.storeDetail=resp.data.data
                console.log(resp)
            })
            this.showDetailWindow=true;
        },handleClose(){
            this.showDetailWindow=false
        },
        success(storeInfoId){
            console.log(storeInfoId)
            axios.post("/storeInfo/updateState",{
                storeInfoId:storeInfoId,
                stateId:1
            }).then(resp=>{
                alert(resp.data.message)
                this.loadAllStoreList(1,3,null)
                this.showDetailWindow=false
            })
        },
        freeze(storeInfoId){
            console.log(storeInfoId)
            axios.post("/storeInfo/updateState",{
                storeInfoId:storeInfoId,
                stateId:0
            }).then(resp=>{
                alert(resp.data.message)
                this.loadAllStoreList(1,3,null)
                this.showDetailWindow=false
            })
        }

    },created(){
        this.loadAllStoreList(1,3,null)
    }
})